package com.rex.saas.interceptor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Description 拦截器注册
 * @Author dengzaojian
 * @Date 2024/12/18
 * @Version 1.0
 */
@Configuration
public class RegistryInterceptor implements WebMvcConfigurer {

    @Autowired
    private AuthInterceptor authInterceptor;

    /**
     * 注册用户认证拦截器，配置放行请求
     *
     * @param registry 注册对象
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        InterceptorRegistration interceptorRegistration = registry.addInterceptor(authInterceptor);
        interceptorRegistration.addPathPatterns("/**");
        interceptorRegistration.excludePathPatterns(//添加不拦截路径
                "/task/trigger",            //登录
                "/mqtt/up",            //登录
                "/mqtt/down",            //登录
                "/register",            //登录
                "/resetPassword",            //登录
                "/resetMail",            //登录
                "/ctRegister",            //登录
                "/getRegisterVcode",            //登录
                "/ctLogin",            //登录
                "/login",            //登录
                "/rex/saas/passwordReset",            //登录
                "/rex/saas/api/task/trigger",            //登录
                "/refreshToken",            //刷新Token
                "/file/upload",            //上传文件
                "/file/download/**",            //下载文件
                "/monitor/**",            //
                "/dataV/**",            //数据大屏接口
                "/error/**",            //错误信息
                "/**/*.html",            //html静态资源
                "/**/*.js",              //js静态资源
                "/**/*.css",             //css静态资源
                "/**/*.png",             //css静态资源
                "/**/*.jpg",             //css静态资源
                "/**/*.woff",
                "/**/*.woff2",
                "/**/*.gif",
                "/**/*.eot",
                "/**/*.svg",
                "/**/*.ttf");
    }
}
